<template>
  <el-dialog :title="dialogTit" :visible.sync="projectbuildingVisible" :close-on-click-modal="false"
             :append-to-body="true" :modal-append-to-body="false">
    <div class="mod-prod-info">
      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
        <el-form-item label="面料+胶水克重" prop="mcjskz">
          <el-input v-model="dataForm.mcjskz" placeholder="面料+胶水克重"></el-input>
        </el-form-item>
        <el-form-item label="面料+胶水厚度" prop="mcjshd">
          <el-input v-model="dataForm.mcjshd" placeholder="面料+胶水厚度"></el-input>
        </el-form-item>
        <el-form-item label="底纸厚度" prop="dzhd">
          <el-input v-model="dataForm.dzhd" placeholder="底纸厚度"></el-input>
        </el-form-item>
        <el-form-item label="底纸克重" prop="dzkz">
          <el-input v-model="dataForm.dzkz" placeholder="底纸克重"></el-input>
        </el-form-item>
        <el-form-item label="初粘" prop="cz">
          <el-input v-model="dataForm.cz" placeholder="初粘"></el-input>
        </el-form-item>
        <el-form-item label="剥离力" prop="bll">
          <el-input v-model="dataForm.bll" placeholder="剥离力"></el-input>
        </el-form-item>
        <el-form-item label="判定结果" prop="pdjg">
          <el-input v-model="dataForm.pdjg" placeholder="判定结果"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="biz">
          <el-input v-model="dataForm.biz" placeholder="备注"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
                     @click="dataFormSubmit()">确定</el-button>
        </el-form-item>
      </el-form>
    </div>
  </el-dialog>

</template>
<script>
import { getUUID } from '@/utils'
import {Debounce} from "@/utils/debounce";
export default {
  name:'projectbuilding',
  data(){
    return {
      dialogTit: '维护产品信息',
      projectbuildingVisible : false,
      dataForm: {
        id: '',
        mainId: '',
        mcjskz: '',
        mcjshd: '',
        dzhd: '',
        dzkz: '',
        cz: '',
        bll: '',
        pdjg: '',
        biz: ''
      },
      dataRule: {
        mcjskz: [
          { required: true, message: '楼栋名称不能为空', trigger: 'blur' },
          { pattern: /\s\S+|S+\s|\S/, message: '请输入正确的楼栋名称', trigger: 'blur' }
        ]
      }
    }
  },
  methods :{
    init(mainId){
      this.projectbuildingVisible = true
      this.dataForm.mainId=mainId
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
      })
    },
    dataFormSubmit: Debounce(function () {
      let proObj = {
        'id': getUUID(),
        'mainId': this.dataForm.mainId,
        'mcjskz': this.dataForm.mcjskz,
        'mcjshd': this.dataForm.mcjshd,
        'dzhd': this.dataForm.dzhd,
        'dzkz': this.dataForm.dzkz,
        'cz': this.dataForm.cz,
        'bll': this.dataForm.bll,
        'pdjg': this.dataRule.pdjg,
        'biz': this.dataForm.biz
      }
      this.projectbuildingVisible = false
      this.$emit('refreshBuilding',proObj)
    })
  }

}
</script>
